{extend name="index/iframe" /}

{block name="content"}
<form class="layui-form layui-form-my" action="">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">选择游戏</label>
        <div class="layui-input-block select-box">
            {MyTag:game type='manage' /}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上传素材</label>
        <div class="layui-input-block">
            <div class="dropzone" id="upload" style="width: 100%;"></div>
            <input type="hidden" name="file" id="file">
        </div>
    </div>
</form>
{/block}

{block name="css"}
<link rel="stylesheet" type="text/css" href="__STATIC__/js/dropzone/dropzone.css">
{/block}

{block name="js"}
<script src="__STATIC__/js/dropzone/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/js/dropzone/dropzone.min.js"></script>
<script>
    Dropzone.autoDiscover = false;
    $("#upload").dropzone({
        url: '{:url("ChannelMaterial/add")}',
        paramName: 'file',
        maxFiles: 1,
        maxFilesize: 50, //MB,
        uploadMultiple: false, //是否一次提交多个文件
        dictCancelUpload: '上传中..',
        addRemoveLinks: true,
        dictRemoveFile: '删除',
        autoDiscover: false,
        dictDefaultMessage: '选择游戏素材包，文件后缀为zip或者rar',
        dictMaxFilesExceeded: '最多只能上传一个文件',
        sending: function(file, xhr, formData) {
            xhr.setRequestHeader("game", $('#game_id').val());
        },
        success: function(file, jsonStr) {
            var json = $.parseJSON( jsonStr );
            if(json.code==0){
                $('.dz-remove').remove();
            }
            file.previewTemplate.appendChild(document.createTextNode(json.msg));
        }
    });

    layui.use(['form'], function(){
        var form = layui.form
            ,$ = layui.$;
    });
</script>
{/block}